//
//  LawyerListViewController.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/2/7.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "LawyerListViewController.h"
#import "LawyerView.h"
#import "souSuoViewController.h"
@interface LawyerListViewController ()
@property(nonatomic,strong)LawyerView *aView;
@end

@implementation LawyerListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"律师列表";
    
    UIBarButtonItem *pulishButton=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"搜索"] style:UIBarButtonItemStylePlain target:self action:@selector(souSuo)];
    
    [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:pulishButton,nil]];
    
    _aView=[LawyerView new];
    [self.view addSubview:_aView];
    [_aView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    _aView.viewController=self;
    [self GetShengArr];
}

-(void)souSuo{
    souSuoViewController *souSuo=[[souSuoViewController alloc] init];
    souSuo.city_name=[_aView.selectAddDic objectForKey:@"name"];
    souSuo.abc=3;
    [ZQTools pushNextViewController:self  andRootController:souSuo];
}
-(void)GetShengArr{
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:@"0",@"id", nil];
    [ZQTools AFNPostDataUrl:@"api/index/area_list" Dict:dic andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {
        _aView.shengArr=responseObject;
        for (int i=0; i<_aView.shengArr.count; i++) {
            NSDictionary *dic1=responseObject[i];
            NSString *shortname=[dic1 objectForKey:@"shortname"];
            if ([shortname isEqualToString:@"重庆"]) {
                [self getShiArr:dic1];
                continue;
            }
        }
        
    } anderrorBlock:nil];
}
-(void)getShiArr:(NSDictionary *)dic1{
    NSNumber *gtype_one_id=[dic1 objectForKey:@"id"];
    NSString *idt=[NSString stringWithFormat:@"%@",gtype_one_id];
    NSDictionary *dic2=[NSDictionary dictionaryWithObjectsAndKeys:idt,@"id", nil];
    
    [ZQTools AFNPostDataUrl:@"api/index/area_list" Dict:dic2 andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {

        _aView.shiArr=responseObject;
        _aView.selectAddDic=responseObject[0];
        [self getAnJian];

    } anderrorBlock:nil];
}
-(void)getAnJian{
    
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:@"0",@"ct_id", nil];
    [ZQTools AFNPostDataUrl:@"api/index/case_type" Dict:dic andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {
        _aView.anJianArr=responseObject;
        [self getAnJian2:responseObject[0]];
        
    } anderrorBlock:nil];
}

-(void)getAnJian2:(NSDictionary *)dict{
    
    NSNumber *gtype_one_id=[dict objectForKey:@"ct_id"];
    NSString *idt=[NSString stringWithFormat:@"%@",gtype_one_id];
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:idt,@"ct_id", nil];
    [ZQTools AFNPostDataUrl:@"api/index/case_type" Dict:dic andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {
        _aView.anJianArr2=responseObject;
        _aView.selectAnJianDic=responseObject[0];
        [_aView creatView];
        
    } anderrorBlock:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
